package BSServer;

import java.io.DataOutputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) {
        try {
            //创建ServerSocket对象，同时注册端口
            ServerSocket serverSocket = new ServerSocket(8081);

            //接收客户端发来的数据
            while (true) {
                //创建一个等待客户端的端口
                Socket socket = serverSocket.accept();
                System.out.println("有人上线了" + socket.getRemoteSocketAddress());
                new ServerReadTheard(socket).start();
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
